the problem of using querystring
-
I use the following format to redirect from a search input text, but I have the following poblem: when the input textbox (i.e. TextBox_Search.Text ) contains ++ or #, it results in wrong result: e.g if I input "C++", then search_text is not "C++" but only "C"; if I input "C#", then search_text is empty! this is maybe due to string problem, but I do not how to deal with these cases. protected void Button_Search_Click(object sender, EventArgs e) { Response.Redirect("~/BookList.aspx?search_text=" + TextBox_Search.Text + "&search_based=" + DropDownList_search_term.SelectedValue + "&display_content=booksearch"); } string search_text = Request.QueryString.Get("search_text");
-
I use the following format to redirect from a search input text, but I have the following poblem: when the input textbox (i.e. TextBox_Search.Text ) contains ++ or #, it results in wrong result: e.g if I input "C++", then search_text is not "C++" but only "C"; if I input "C#", then search_text is empty! this is maybe due to string problem, but I do not how to deal with these cases. protected void Button_Search_Click(object sender, EventArgs e) { Response.Redirect("~/BookList.aspx?search_text=" + TextBox_Search.Text + "&search_based=" + DropDownList_search_term.SelectedValue + "&display_content=booksearch"); } string search_text = Request.QueryString.Get("search_text");
why dont you use :
Server.UrlEncode("C#")
ThusResponse.Redirect("~/BookList.aspx?search_text=" + Server.UrlEncode(TextBox_Search.Text) + "&search_based=" + Server.UrlEncode(DropDownList_search_term.SelectedValue) + "&display_content=booksearch");
And also from client if you are using Javascript to send data use :
javascript: encodeURIComponent("C#")
I think this would cure your problem. Cheers. :cool:Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
why dont you use :
Server.UrlEncode("C#")
ThusResponse.Redirect("~/BookList.aspx?search_text=" + Server.UrlEncode(TextBox_Search.Text) + "&search_based=" + Server.UrlEncode(DropDownList_search_term.SelectedValue) + "&display_content=booksearch");
And also from client if you are using Javascript to send data use :
javascript: encodeURIComponent("C#")
I think this would cure your problem. Cheers. :cool:Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
thanks, it seems that I need to learn a lot! there are many things I have not known!
-
thanks, it seems that I need to learn a lot! there are many things I have not known!
:cool: More you work.. .more you learn.. a simple concept... :) :)
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
:cool: More you work.. .more you learn.. a simple concept... :) :)
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
Hi, Abhishek, I have one more similar problem, which I do not know who to deal with: similary, I have one image field bind to the book cover, which is saved as the file path in a database, once again, I found that if the file contains C++ then the image file can not be correctly bound to the image field. do you have any idea why for this case? <asp:TemplateField HeaderText="Book Cover"> <ItemTemplate> <img style="height: 80px; width: 65px" src="<%# DataBinder.Eval(Container.DataItem, "BookCover") %>" alt="not available"/> </ItemTemplate> </asp:TemplateField>
-
Hi, Abhishek, I have one more similar problem, which I do not know who to deal with: similary, I have one image field bind to the book cover, which is saved as the file path in a database, once again, I found that if the file contains C++ then the image file can not be correctly bound to the image field. do you have any idea why for this case? <asp:TemplateField HeaderText="Book Cover"> <ItemTemplate> <img style="height: 80px; width: 65px" src="<%# DataBinder.Eval(Container.DataItem, "BookCover") %>" alt="not available"/> </ItemTemplate> </asp:TemplateField>
Same as the earlier.. Does this work correctly ?
" alt="not available"/>
:rose:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
Same as the earlier.. Does this work correctly ?
" alt="not available"/>
:rose:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
actually, I have tried this way, it does not work, but as you proposed again, then I tried again, and I find that the object should be conveted into string first, then it works! i.e.: <img style="height: 80px; width: 65px" src="<%# Server.UrlEncode(DataBinder.Eval(Container.DataItem, "BookCover").ToString()) %>" alt="not available"/> OK, great, I have got lot of help from you! You are quit active in this area, hopefully, more help can be obtained from you!
-
actually, I have tried this way, it does not work, but as you proposed again, then I tried again, and I find that the object should be conveted into string first, then it works! i.e.: <img style="height: 80px; width: 65px" src="<%# Server.UrlEncode(DataBinder.Eval(Container.DataItem, "BookCover").ToString()) %>" alt="not available"/> OK, great, I have got lot of help from you! You are quit active in this area, hopefully, more help can be obtained from you!
Yaah... Right... Server.UrlEncode expects the parameter as string .. :)
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.