Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <asp:TemplateField>
- <ItemTemplate>
- <asp:HyperLink ID="HyperLink1" runat="server"
- NavigateUrl='<%# Eval("Post_ID", "~/RCA.aspx?Post_ID={0}") %>'
- Text="SEND"></asp:HyperLink>
- </ItemTemplate>
- <asp:Button ID="btnRCA" runat="server" onclick="Button1_Click"
- Text="Assign RCA" Width="147px" />
- //When linked to RCA.aspx from Home.aspx, a parameter called ShowButton=1 is included
- //in the URL.
- <asp:HyperLink ID="HyperLink1" runat="server"
- NavigateUrl='<%# Eval("Post_ID", "~/RCA.aspx?Post_ID={0}&ShowButton=1") %>'
- Text="SEND"></asp:HyperLink>
- //By default, since you want the button to NOT appear for all incoming traffic EXCEPT
- //that which came from Home.aspx, the button's Visible property is set to false.
- <asp:Button ID="btnRCA" runat="server" onclick="Button1_Click"
- Text="Assign RCA" Width="147px" Visible="false" />
- protected void Page_Load(object sender, EventArgs e)
- {
- //If the querystring has a parameter called ShowButton and it's equal to "1",
- //then set the button to Visible = true.
- //Else, do nothing, keeping the button in it's default, Visible=false state.
- //By putting this in an "IsPostback == false" check, you can guarantee that this will
- //only happen on first page_load, and won't be triggered again even if you do other
- //actions in the page that cause Postback
- //For example, if you don't use this !IsPostback check, and you end up creating some
- //new function that causes the button to be hidden again, but then you make a
- //selection from a dropdown list that causes postback, you will trigger the call to
- //make the button Visible again, even though that's probably what you don't want at
- //this point, since your other new function set it to Visible = false.
- if (!IsPostback)
- {
- if (Request.QueryString["ShowButton"] == "1")
- {
- RCAbtn.Visible = true;
- }
- if (Request.QueryString["Post_ID"] != null)
- {
- //do whatever you need to with the post ID
- }
- }
- }
- Response.Redirect("RCA.aspx?Post_ID=1234"); //button will be invisible
- Response.Redirect("RCA.aspx?Post_ID=1234&ShowButton=1"); //button will be visible
- string currenturl = Request.Url.ToString(); //get the current URL
- string urlToSend = currenturl.Substring(0, currenturl.IndexOf("?")); //cut off the QueryString entirely
- urlToSend += "?Post_ID=" + Request.QueryString["Post_ID"]; //re-append the Post_ID
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Request.QueryString["Post_ID"] != null)
- {
- btnRca.Visible = true;
- }
- }
Add Comment
Please, Sign In to add comment